package com.util.excelUtil.ExcelEntity;

import com.util.excelUtil.ExportExcelUtil;
import com.util.excelUtil.annotation.ExcelTitle;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description:
 * @Author: yangzhiwei
 * @Date: 2021/1/22 13:52
 */
public class AATest {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, IOException {
//        ExportExcelUtil exportExcelUtil = new ExportExcelUtil();
//        exportExcelUtil.addSpecifiedTitle("aa","aaaa");
//        AA aa = new AA();
//        aa.setAa("aa1");
//        aa.setBb("bb1");
//
//        AA aa1 = new AA();
//        aa1.setAa("aa2");
//        aa1.setBb("bb2");
//        List list = new ArrayList<>();
//        list.add(aa);
//        list.add(aa1);
//        XSSFWorkbook book = exportExcelUtil.exportWorkBook(list);
//
//        XSSFSheet sheet = book.getSheet("sheet1");
//        System.out.println("sheet" + sheet);
//
//        FileOutputStream fileOutputStream = new FileOutputStream("F:\\excel\\b.xlsx"); //F:\excel\\
//        book.write(fileOutputStream);


          Class aa = ExcelTitle.class;
        System.out.println(Arrays.toString(aa.getAnnotations()));
        for (Annotation annotation : aa.getAnnotations()) {
            if (annotation instanceof Target) {
                System.out.println("target: " +  annotation.annotationType());
                System.out.println("target: " + annotation.toString());
            }
            if (annotation instanceof Retention) {
                System.out.println("Retention: " +  annotation.annotationType());
                System.out.println("Retention: " + annotation.toString());
            }
        }
    }
}
